export default defineNuxtRouteMiddleware((to, from) => {
  const userStore = useUserStore();
  const isAuth = to.path.startsWith("/admin") || to.path.startsWith("/dev");
  if (isAuth) {
    const isLoggedIn = userStore.token;
    if (!isLoggedIn) {
      return navigateTo("/login");
    } else {
      if (!to.meta.noAuth && !userStore.menus.includes(to.name as string)) {
        return navigateTo("/login");
      }
    }
  }
});
